//
//  ByBetRecordTitleCell.m
//  caipiao_ios
//
//  Created by mc on 2018/8/13.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "ByBetRecordTitleCell.h"

@implementation ByBetRecordTitleCell

+ (instancetype)cellWithTableView:(UITableView*)tableView{
    
    static NSString *cellIdentifier = @"ByBetRecordTitleCell";
    ByBetRecordTitleCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        self.contentView.backgroundColor = BY_BACKGROUND_COLOR;
        [self initViews];
    }
    return self;
}

-(void)setNetModel:(ByNetModel *)netModel{
    _netModel = netModel;
    
    [self.iconView sd_setImageWithURL:[NSURL URLWithString:_netModel.pic] placeholderImage:DEFAULT_IMAGE];
    self.titleLabel.text = _netModel.name;
    self.timeLabel.text = [NSString stringWithFormat:@"第%@期",_netModel.number];
}

- (void)initViews{
    UIView *backgroundView = [[UIView alloc] init];
    [self.contentView addSubview:backgroundView];
    [backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(5);
        make.right.equalTo(self.contentView).offset(-5);
        make.top.equalTo(self.contentView).offset(10);
        make.bottom.equalTo(self.contentView).offset(0);
    }];
    backgroundView.layer.cornerRadius = 10;
    backgroundView.backgroundColor = [UIColor whiteColor];
    
    UIImageView *iconView = [[UIImageView alloc] init];
    [backgroundView addSubview:iconView];
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(backgroundView).offset(10);
        make.centerY.equalTo(backgroundView).offset(0);
        make.size.mas_equalTo(CGSizeMake(50, 50));
    }];
    iconView.backgroundColor = BY_BACKGROUND_COLOR;

    UILabel *titleLabel = [[UILabel alloc] init];
    [backgroundView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(iconView.mas_right).offset(10);
        make.top.equalTo(iconView).offset(5);
        make.height.mas_equalTo(@20);
        make.right.equalTo(backgroundView).offset(-10);
    }];
    titleLabel.text = @"大乐透";
    titleLabel.font = FONT(14);
    titleLabel.textColor = [UIColor blackColor];
    titleLabel.textAlignment = NSTextAlignmentLeft;
    
    
    UILabel *timeLabel = [[UILabel alloc] init];
    [backgroundView addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(titleLabel.mas_left).offset(0);
        make.top.equalTo(titleLabel.mas_bottom).offset(5);
        make.height.mas_equalTo(@15);
        make.right.equalTo(titleLabel.mas_right).offset(0);
    }];
    timeLabel.text = @"第10000期";
    timeLabel.font = FONT(14);
    timeLabel.textColor = [UIColor lightGrayColor];
    timeLabel.textAlignment = NSTextAlignmentLeft;
    
    self.iconView = iconView;
    self.timeLabel = timeLabel;
    self.titleLabel = titleLabel;
    
    
    
    
}

@end
